<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
		/* .layui-table-cell {
		    height: auto ;
		    white-space: normal;
		} */
	</style>
</head>
<body>
	<div class="layuimini-container">
		<div class="layuimini-main">
			<fieldset class="table-search-fieldset layuimini-container">
				<legend>搜索信息</legend>
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item" style="margin-bottom: 5px;">
						<div class="layui-inline">
							<label class="layui-form-label">账户ID</label>
							<div class="layui-input-inline">
								<select id="acc_name" lay-verify="required" lay-search="" autocomplete="off" >
									<option value="">直接选择或搜索选择</option>
										{volist name="acc_list" id='ac'}
											<option value="{$ac.id}" >{$ac.name_id}</option>
										{/volist}
						        </select>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">客户</label>
							<div class="layui-input-inline">
								<select id="customer_id" lay-verify="required" lay-search="" autocomplete="off" >
									<option value="">直接选择或搜索选择</option>
										{volist name="cu_list" id='cu'}
											<option value="{$cu.id}" >{$cu.name}</option>
										{/volist}
						        </select>
							</div>
						</div>
						<div class="layui-inline">
							<button type="button" class="layui-btn layui-btn-primary acc_ss"><i class="layui-icon"></i> 搜 索</button>
						</div>
					</div>
				</form>
			</fieldset>
			<table class="layui-hide" id="accTableId" lay-filter="accTableFilter"></table> 
			<script type="text/html" id="toolbar">
				<div class="layui-btn-container">
					<button class="layui-btn layui-btn-success layui-btn-sm data-add-btn" lay-event="acc_refund"> 账户退款</button>
				</div>
			</script>
			<script type="text/html" id="accTableBar">
				{{d.status<=0?'<a class="layui-btn layui-btn-success layui-btn-xs layui-btn-warm" lay-event="acc_edit">修改</a>':''}}
				{{d.status<=0?'<a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-warm" lay-event="acc_del">删除</a>':''}}
			</script>
			<script type="text/html" id="acc_list">
				<span onmouseover=get_msg(this) data-msg="{{d.reject}}" style="color: red;font-weight: bold;{{d.status == -1?'':'display:none;'}}">驳回</span>
				<span  style="color: #03A9F4;font-weight: bold;{{d.status == 0?'':'display:none;'}}">审核中</span>
				<span  style="color: #4CAF50;font-weight: bold;{{d.status == 1?'':'display:none;'}}">退款成功</span>
			</script>
		</div>
	</div>
</body>
</html>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
function get_msg(obj){
	var str = $(obj).attr('data-msg');
	layer.tips(str,$(obj));
}
//账户退款修改
function get_acc_save(id){
	layer.open({
        type: 2,
        title:'修改账户退款',
        area: ['60%', '60%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('save_acc_refund')}?id="+id 
    });
    //layer.full(index);
}
// 账户退款
function get_acc_add(){
	layer.open({
        type: 2,
        title:'添加账户退款',
        area: ['60%', '70%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('add_acc_refund')}"
    });
    //layer.full(index);
}

	var form,layer,element,table,$;
	layui.use([ 'form', 'table', 'layedit', 'laydate', 'element' ], function() {
		form = layui.form, layer = layui.layer,table = layui.table,$ = layui.jquery;
		pageLoading();
		table.render({
			elem: '#accTableId',
			height: 'full-150',
			id:'accReload',
			url: '{:url("list_acc_refund")}?t=json',
			method : 'post',
			toolbar: '#toolbar',
			cols: [[
				{ field: 'code', title: '编号' },
				{ field: 'channel_name', title: '渠道名称' },
				{ field: 'name_id', title: '账户ID' },
				{ field: 'customer_name', title: '客户名称' },
				{ field: 'currency', title: '应退账号币' },
				{ field: 'rebate', title: '客户/端口/销售(%)',templet: function(d){
					return d.rebate + ' / '+ d.channel_rebate+ ' / '+ d.sell_rebates
				} },
			    { field: 'status', title: '状态' ,templet:'#acc_list'},
				{ field: 'screenshot_url', title: '退款凭证',templet: function(d){
					return d.screenshot_url?'<img layer-src="'+d.screenshot_url+'" src="'+d.screenshot_url+'">':''
				}},
			    { field: 'audit_proof_url', title: '财务凭证',templet: function(d){
					return d.audit_proof_url?'<img layer-src="'+d.audit_proof_url+'" src="'+d.audit_proof_url+'">':''
				}},
				{ field: 'note', title: '备注' },
				{ field: 'media_name', title: '媒介' },
			    { field: 'create_time', title: '时间'},
				{ title: '操作',fixed: 'right', toolbar: '#accTableBar', align: "center" }
			]],
			limit: 30,
			page: true,
			skin: 'line',
			// even: true,
			loading:false,
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});
		// 监听搜索操作
		$('.acc_ss').click(function(){
			pageLoading();
			var name = $("#acc_name").val();
			var customer_id = $("#customer_id").val();
			table.reload('accReload', {
				  url: '{:url("list_acc_refund")}?t=json',
				  where:{name:name,customer_id:customer_id}
				});
		});
		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(accTableFilter)', function (obj) {
			switch (obj.event) {
				case 'acc_refund':
					//账户退款
					get_acc_add();
				break;
			}
			
		});
		//监听操作栏
		table.on('tool(accTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'acc_edit':
					get_acc_save(data.id);
				break;
				case 'acc_del':
					layer.confirm('你确定要删除吗?', function(index){
						layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
					  	$.post("{:url('Refund/del_acc_refund')}?t=json",{id:data.id},function(data){
						  	layer.closeAll();
							if (data['code'] == 1) { 
								obj.del();
								layer.msg(data['msg'], { icon : 6 });
							} else {
								layer.msg(data['msg'], { icon : 5 });
							}
					  	})
					});    
				break;
			}
			
		});
		//监听行单击事件
		table.on('row(accTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});
	});
	//重载数据表
	function get_acc(msg){
		table.reload('accReload', {
			  url: '{:url("list_acc_refund")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>